<?php $this->set('title', $thisSurvey['Survey']['name']); ?>

<?php $session->flash();?>
<div class="header"><?php echo($thisSurvey['Survey']['name']); ?></div>
<?php
if($registered) {
	echo($form->create('Survey', array('controller' => 'Surveys', 'action' => 'submit_answer')));
} else {
	echo($form->create('User', array('controller' => 'Users', 'action' => 'registerForSurvey/'.$survey_id)));
}
	echo($form->hidden('user_id', array('value' => $user_id)));
	echo($form->hidden('survey_id', array('value' => $survey_id)));
	echo($form->hidden('question_number', array('value' => $question_number)));
	echo($form->hidden('questions_surveys_id', array('value' => $questions_surveys_id)));
	if($question_number > 0){
		echo($form->hidden('question_id', array('value' => $questions[$question_number-1]['Question']['id'])));
		echo('<p>'.$question_number.'. '.$questions[$question_number-1]['Question']['text']."<br />");
		echo('<div style="padding-left:30px;">');
		
		$i = 0;
		foreach($answers as $answer) {
			$answer_text[$answer['Answer']['id']] = chr(($i++)+65).'. '.$answer['Answer']['text'];
		}
		if(!empty($answer_text)) {
			echo($form->error('answer_id', array('class' => 'errMsg')));
			echo($form->radio('answer_id', $answer_text, array('separator' => "<br />", 'legend' => false)));
		}
		echo('</div>');
		echo('</p>');
	}
	else{
		echo('This survey does not contain any questions yet.<br />');
	}
?>
<br />
<?php
if($question_number != 1) {
	echo('<div style="float:left;padding-right:5px;">');
	echo($html->link('Back', array('controller' => 'surveys', 'action' => 'user_view', '0' => $this->params['pass']['0'], '1' => $question_number-1)));
	echo('</div>');
}
echo('<div style="float:left;">');
if($registered) {
	echo($form->submit('Submit Answer'));
} else {
	echo($form->submit('Register'));
}
echo('</div>');
if($question_number != count($questions)) {
	echo('<div style="float:left;padding-left:5px;">');
	echo($html->link('Forward',  array('controller' => 'surveys', 'action' => 'user_view', '0' => $this->params['pass']['0'], '1' => $question_number+1)));
	echo('</div>');
} else {
	echo($form->hidden('end', array('value' => 'true')));
}
echo($form->end());
?>
<div class="clear">&nbsp;</div>